<?php
/**
 * @package Admin
 * @author Henrique Droog <henridroog@gmail.com>
 * @name RoleSubmenu
 * @since 05/04/2011
 * @version 1.0
 */
class Admin_Model_RoleSubmenu {

    protected $_status;
    protected $_submenu;
    protected $_role;
    protected $_id;

    public function __construct(array $options = null)
    {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }

    public function __set($name, $value)
    {
        $method = 'set' . $name;
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Propriedade de regra inválida');
        }
        $this->$method($value);
    }

    public function __get($name)
    {
        $method = 'get' . $name;
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Propriedade de regra inválida');
        }
        return $this->$method();
    }

    public function setOptions(array $options)
    {
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
        return $this;
    }

    public function setStatus($status)
    {
        $this->_status = $status;
        return $this;
    }

    public function getStatus()
    {
        return $this->_status;
    }

    public function setSubmenu($submenu_id)
    {
        $this->_submenu = $submenu_id;
        return $this;
    }

    public function getSubmenu()
    {
        return $this->_submenu;
    }

    public function setRole($role_id)
    {
        $this->_role = (int) $role_id;
        return $this;
    }

    public function getRole()
    {
        return $this->_role;
    }

    public function setId($id)
    {
        $this->_id = (int) id;
        return $this;
    }

    public function getId()
    {
        return $this->_id;
    }
}